
<h2 style='text-align:center'>砍价商品管理</h2>

<div id='FreeCon_GoodsListArea'></div>






<div style='text-align:center;margin:20px auto'><button id='FreeCon_AddFreeBtn'>添加砍价商品</button></div>

<script>

FreeCon_Init();

function FreeCon_Init(){
	Ajax2({type:'FreeGoodsGetList',store_id:StoreInfo.id},function(res){
		if(!/^\[{"id":.*$/.test(res)){
			$('#FreeCon_GoodsListArea').html('');
			return;
		}
	//	C(res);
		var info = JSON.parse(res);

		var str = '';
		for(var i=0;i<info.length;i++){
			str += "<div style='display:flex;border-bottom:7px solid #fee;font-size:13px;margin:15px 0;'>";
			str += "<div style='border:1px solid #eef;width:100px;height:100px'>";
			if(info[i].banner){
				var img_addr = upyun_shop_img+info[i].banner;
			}else{
				var img_addr = '../Public/Image/base.png';
			}
			str += "<img src='"+img_addr+"' style='width:100%;height:100%' onerror=this.src='../Public/Image/base.png' alt='呵呵了' ></div>";
			str += "<div style='flex:1;padding:0 5px;box-sizing:border-box;color:#999'>";
			//标题
			str += "<div style='font-size:14px;height:40px;word-break:break-all;overflow:hidden;color:#333'>"+info[i].title+"</div>";		
			str += "<div style='height:20px;display:flex;margin:8px 0'>";
			//价格
			str += "<div style='flex:1;color:red;font-weight:bold'>￥："+info[i].price+"</div>";
			str += "</div>";

			str += "<div style='height:20px;display:flex'>";
			//状态
			switch(info[i].free_stat){
				case 1:case '1':var stat_str = '<text style="color:blue">正常</text>';break;
				case 2:case '2':var stat_str = '已封禁';break;
				default :
					var stat_str = '审核中';break;
			}
			str += "<div style='width:60px'>"+stat_str+"</div>";

			str += "<div style='flex:1;text-align:right'>";
	
			str += "<span style='padding:1px 7px;background:#aaf;color:#fff;border-radius:5px' onclick=FreeCon_FreeGoodsDel("+info[i].id+",'"+info[i].banner+"')>关闭</span>　";


			str += "<span style='padding:1px 7px;background:#aaf;color:#fff;border-radius:5px' 	onclick=FreeCon_FreeGoodsOrders("+info[i].id+")>查看订单</span>　";
			str += "</div></div></div></div>";
		}
		$('#FreeCon_GoodsListArea').html(str);
	},after_url);
}


	//查看砍价商品的订单列表
	function FreeCon_FreeGoodsOrders(free_id){
		C(free_id);
	}



	//添加砍价商品按钮
	$('#FreeCon_AddFreeBtn').click(function(){
		Ajax('',function(res){
			$('.ContentItem').hide();
			$('#FreeAddArea').html(res).show();
		},'Template/FreeCon_AddFree.html');
	});




	//关闭(删除)砍价商品状态 
	function FreeCon_FreeGoodsDel(free_id,banner){
		if(!confirm('确认该操作？')){
			return;
		}
		var store_id = StoreInfo.id;
		Ajax2({type:'FreeGoodsDel',free_id:free_id,store_id:store_id,banner:banner},function(res){
			if(res == 'ok'){
				A('操作成功！');
				FreeCon_Init();
			}
		},after_url);
	}

</script>